package TUILayer;
import java.util.Scanner;
import ControlLayer.DVDCtr;
/**
 * User interface to the DVD controller
 * @author(kbh)
 * @version(2005.03.31)
 * (FEN): 2006.02.24: Comments translated into English
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 * (KBH): 2008.10.24: dvdmenu changed to If                   
 */

public class DvdUI
{
    private DVDCtr dvdCtr;//DVD UI must know the DVD controller 
    
    public DvdUI()
    {
        
    }
    
    public void start()
    {
        dvdCtr = new DVDCtr();
        dvdMenu();
    }
    
    public void dvdMenu()
    {   
        boolean exit = false;
        while(!exit)
        {
            //show menu and return the user's choise
            int choise =   writeDVDMenu();
            switch(choise){
                case 1:
                findDVD();
                break;
        
                case 2:
                createDVD();
                break;
    
                case 3:
                createCopy();
                break;
        
                case 4:
                deleteDVD();
                break;
        
                case 5:
                listAllDvds();
                break;
        
                default:
                exit = true;
            }
        }
    }
    /*
   
     */
    
    private int writeDVDMenu()
    {
           // creates an object keyboard to read data from the keyboard
            Scanner keyboard = new Scanner(System.in);
            System.out.println("\f *** DVD Menu ***");
            System.out.println(" (1) Show DVD information");
            System.out.println(" (2) Create DVD description");
            System.out.println(" (3) Create DVD specimen");
            System.out.println(" (4) Delete DVD");
            System.out.println(" (5) Show current DVD list");
            System.out.println(" (6) Return");
            System.out.print("\n Make your choise: ");
            
            int choise = keyboard.nextInt();
            return choise;
    }
    private int inputDVDNo()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type DVD number: ");
        int no = keyboard.nextInt();
        return no;
    }
        
    private String inputTitle()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type DVD title: " );
        String title = keyboard.nextLine();
        return title;
    }
    
     private String inputArtist()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type DVD artist: " );
        String artist = keyboard.nextLine();
        return artist;
    }
    
    private int inputReleaseYear()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type DVD releaseYear: ");
        int releaseYear = keyboard.nextInt();
        return releaseYear;
    }
    
    private int inputId()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type DVD id: ");
        int id = keyboard.nextInt();
        return id;
    }
    
    private int inputCopyNo()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the copy number: ");
        int no = keyboard.nextInt();
        return no;
    }
    
     private void waitForSomething(){
        // creates an object keyboard to read data from the keyboard
        System.out.println();
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter your faverite number to continue: ");
        keyboard.nextLine();
        
    }
    //there is need for more methods to read information about DVDs
    //and methods to display the information
   
    private void findDVD()
    {     
        int no = inputDVDNo();
        dvdCtr.findDVD(no);
        waitForSomething();
        //dvdCtr.(no)
        //is to be changed when the DVD controller is completed
        //String dvd = dvdCtr.findDVD(no);
    }
    
   
    private void createDVD()
    {   
        String titel,artist;
        int id,releaseYear;
        id = inputId();
        titel = inputTitle();
        artist = inputArtist();
        releaseYear = inputReleaseYear();
        
        dvdCtr.createDVD(id,titel,artist,releaseYear);        
    }
   
    
    private void createCopy()
    {
        
    }
    
    private void deleteDVD()
    {
        int no = inputDVDNo();
        dvdCtr.deleteDVD(no);
        waitForSomething();
    
        //id = dvdCtr.findDVD(no);
        //dvdCtr.deleteDvd(id);
    }
    private void listAllDvds(){
        dvdCtr.listAllDvds();
        waitForSomething();
    }
}